<?php
include 'gmlp.php';

$file = 'gmlp.txt';
if (isset($_GET['f']) && is_file($_GET['f']))
	$file = $_GET['f'];

$def = 'gmlp_def.php';
$func = 'gmlp_func.php';
if ($file == 'markdown.txt') {
	$def = 'markdown.php';
	$func = NULL;
}
if ($file == 'textile.txt') {
	$def = 'textile.php';
	$func = NULL;
}

// initialize the data; loading to definitions and functions:
if (!gmlp_open($def,$func))
	exit("Error with $def.");

if ($file != 'markdown.txt' && $file != 'textile.txt') {
	// how to add data:
	gmlp_add('inlines',array(
	'/\bGmlp\b/' => 'GMLP',
	'/GMLP/' => '<b>GMLP</b>',
	'/\b(FALSE|TRUE|NULL)\b/' => '<code class="php">$1</code>',
	));

	// how to add/replace block data:
	if (strpos($file,'.php'))
		gmlp_add_block('php',array(
		'begin' => '/^<\?php/',
		'end' => '/^\?>/', // <?php
		'post' => 'gmlp_div_highlightstr_php',
		'last' => 0,
		'newline' => 1,
		));

	// this replaces the 'leadingspace' definition with a special block 
	// function:
	gmlp_add_block('leadingspace',array(
	'begin' => '/^\s{1,8}/',
	'function' => 'gmlp_ls_block',
	));
	// and this includes the function:
	include 'gmlp_func_ls.php';
?>
<!DOCTYPE html>
<title>GMLP</title>
<link href="gmlp.css" rel="stylesheet" type="text/css">
<link href="code.css" rel="stylesheet" type="text/css">
<section>
<?php
}

echo gmlp_convert(file_get_contents($file));
